package com.shop.controller;

import com.shop.pojo.CommonResult;
import com.shop.pojo.UserDTO;
import com.shop.service.IUserEditService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/userEdit")
@Slf4j
public class UserEditController {
    @Resource
    private IUserEditService userEditService;


    @PostMapping("/addUser")
    public CommonResult<Boolean> addUser(@RequestBody UserDTO userDTO) {
        return userEditService.addUser(userDTO);
    }


    @GetMapping("/editUserState")
    public CommonResult<Integer> editUserState(@RequestParam("state") boolean state, @RequestParam("id") String id) {
        return userEditService.editUserState(state, id);
    }

    @PostMapping("/editUser")
    public CommonResult<Integer> editUser(@RequestBody UserDTO userDTO) {
        return userEditService.editUser(userDTO);
    }

    @DeleteMapping("/deleteUser")
    public CommonResult<Integer> removeUserById(@RequestParam("id") int id) {
        return userEditService.removeUserById(id);
    }

}
